package com.example.servlet.response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: sms
 * @description:
 * @author: zhanghz001
 * @create: 2020-11-01 19:48
 **/
@WebServlet("/response1")
public class ResponseDemo1 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("444");
        resp.setContentType("text/html;charset=utf-8");
        //不仅仅是contenttype的事情,还是charsetName的事情
        resp.getOutputStream().write("这是一个寂寞的天,下着有些伤心的雨".getBytes("utf-8"));
        resp.getOutputStream().write("\r\n".getBytes("utf-8"));
        resp.getOutputStream().write("这是一个寂寞的天,下着有些伤心的雨".getBytes());
    }

}
